<template>
  <div>
    <el-form ref="form" :model="paramsintel" label-width="100px" :inline="true">
      <el-form-item label="年份" prop="yearMonth">
        <el-date-picker format="YYYY" value-format="YYYY" style="width: 140px" v-model="paramsintel.year" type="year" placeholder="请选择年月" />
      </el-form-item>
      <el-form-item label-width="50px" label="单位" prop="organizationName">
        <el-input style="width: 140px" v-model="paramsintel.organizationName" placeholder="请输入" @focus="focusWorkArea()" />
      </el-form-item>
      <el-form-item label-width="100px" label="审批状态" prop="examineStatus">
        <el-select
          filterable
          collapse-tags
          collapse-tags-tooltip
          v-model="paramsintel.examineStatus"
          placeholder="审批状态"
          clearable
          style="width: 140px"
        >
          <el-option v-for="dict in examineStatusobj" :key="dict.id" :label="dict.planAuditState" :value="dict.planAuditState" />
        </el-select>
      </el-form-item>
      <el-form-item label=" " prop="" label-width="30px">
        <el-button type="primary" @click="getList1" style="width: 80px">查询</el-button>
        <el-button @click="paramsintelReset" style="width: 80px">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table :key="Math.random()" :data="intelligenceList" height="52vh" border>
      <el-table-column label="序号" type="index"></el-table-column>
      <el-table-column label="年份" prop="year" width="120px"></el-table-column>
      <el-table-column label="工区" prop="organizationName"> </el-table-column>
      <el-table-column label="最后更新时间" prop="updateTime"> </el-table-column>
      <el-table-column label="审批状态" prop="examineStatus"> </el-table-column>
      <el-table-column label="流程步骤" prop="processSteps"> </el-table-column>
      <el-table-column label="操作" width="350">
        <template #default="scope">
          <el-button @click="look(scope.row)">查看</el-button>
          <el-button @click="trajectory(scope.row)">操作轨迹</el-button>
          <el-button v-if="scope.row.showExamine" @click="Approvalfn(scope.row)">审批</el-button>
          <el-button v-if="scope.row.examineStatus == '驳回' && scope.row.createUser == userStore.id" @click="cancelFun(scope.row)">作废</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog title="工区" v-model="isShowWorkArea" width="550px" append-to-body draggable>
      <tree @handleCheckTree="handleCheckTree"></tree>
    </el-dialog>
    <el-dialog title="操作轨迹" v-model="isShowtrajectory" width="80%" append-to-body draggable>
      <el-table :key="Math.random()" :data="operationTrajectory" height="52vh" border>
        <el-table-column label="序号" type="index"> </el-table-column>
        <el-table-column label="操作时间" prop="actiontime"> </el-table-column>
        <el-table-column label="操作人" prop="username"> </el-table-column>
        <el-table-column label="操作" prop="memo"> </el-table-column>
        <el-table-column label="审批意见" prop="actionName"> </el-table-column>
        <el-table-column label="更多意见" prop="comment"> </el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog title="详情" v-model="isShowlook" width="80%" append-to-body draggable>
      <el-table :key="Math.random()" v-if="paramsintel.type == 1" :data="detaildata" height="52vh" border>
        <el-table-column label="序号" type="index"> </el-table-column>
        <el-table-column label="年月" prop="yearMonth"> </el-table-column>
        <el-table-column label="工区" prop="organizationName"> </el-table-column>
        <el-table-column label="桥隧涵名称" prop="btcName"> </el-table-column>
        <el-table-column label="中心里程" prop="overallLength"> </el-table-column>
        <el-table-column label="重点工作" prop="emphasisJob">
          <template #default="scope">
            <p v-for="(item, index) in scope.row.emphasisJob.split(',')" :key="index">
              {{ item }}
            </p>
          </template>
        </el-table-column>
        <el-table-column label="维修数量" prop="">
          <template #default="scope">
            <p v-for="(item, index) in scope.row.maintainNum.split(',')" :key="index">
              {{ item }}
            </p>
          </template>
        </el-table-column>
        <el-table-column label="维修地段" prop="maintainDistrict">
          <template #default="scope">
            <p v-for="(item, index) in scope.row.maintainDistrict.split(',')" :key="index">
              {{ item }}
            </p>
          </template>
        </el-table-column>
        <el-table-column label="创建时间" prop="createTime" />
      </el-table>
      <el-table :key="Math.random()" v-else :data="detaildata" height="52vh" border>
        <el-table-column label="年月" prop="yearMonth"> </el-table-column>
        <el-table-column label="工区" prop="organizationName" />
        <el-table-column label="正线综合修" prop="railComprehensive">
          <template #default="scope">
            <span v-if="scope.row.railComprehensive?.length <= 15">
              {{ scope.row.railComprehensive }}
            </span>
            <span v-else-if="!scope.row.railComprehensive?.length"> --- </span>
            <span v-else>
              <el-popover effect="dark" placement="top-start" :width="400" trigger="hover" :content="scope.row.railComprehensive">
                <template #reference> {{ scope.row.railComprehensive?.slice(0, 15) }}... </template>
              </el-popover>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="正线保养修" prop="railMaintain">
          <template #default="scope">
            <span v-if="scope.row.railMaintain?.length <= 15">
              {{ scope.row.railMaintain }}
            </span>
            <span v-else-if="!scope.row.railMaintain?.length"> --- </span>
            <span v-else>
              <el-popover effect="dark" placement="top-start" :width="400" trigger="hover" :content="scope.row.railMaintain">
                <template #reference> {{ scope.row.railMaintain?.slice(0, 15) }}... </template>
              </el-popover>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="站线保养修" prop="stationMaintain">
          <template #default="scope">
            <span v-if="scope.row.stationMaintain?.length <= 15">
              {{ scope.row.stationMaintain }}
            </span>
            <span v-else-if="!scope.row.stationMaintain?.length"> --- </span>
            <span v-else>
              <el-popover effect="dark" placement="top-start" :width="400" trigger="hover" :content="scope.row.stationMaintain">
                <template #reference> {{ scope.row.stationMaintain?.slice(0, 15) }}... </template>
              </el-popover>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="道岔综合修" prop="turnoutComprehensive">
          <template #default="scope">
            <span v-if="scope.row.turnoutComprehensive?.length <= 15">
              {{ scope.row.turnoutComprehensive }}
            </span>
            <span v-else-if="!scope.row.turnoutComprehensive?.length"> --- </span>
            <span v-else>
              <el-popover effect="dark" placement="top-start" :width="400" trigger="hover" :content="scope.row.turnoutComprehensive">
                <template #reference> {{ scope.row.turnoutComprehensive?.slice(0, 15) }}... </template>
              </el-popover>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="道岔保养修" prop="turnoutMaintain">
          <template #default="scope">
            <span v-if="scope.row.turnoutMaintain?.length <= 15">
              {{ scope.row.turnoutMaintain }}
            </span>
            <span v-else-if="!scope.row.turnoutMaintain?.length"> --- </span>
            <span v-else>
              <el-popover effect="dark" placement="top-start" :width="400" trigger="hover" :content="scope.row.turnoutMaintain">
                <template #reference> {{ scope.row.turnoutMaintain?.slice(0, 15) }}... </template>
              </el-popover>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="正线状态修" prop="railwayStatus">
          <template #default="scope">
            <span v-if="scope.row.railwayStatus?.length <= 15">
              {{ scope.row.railwayStatus }}
            </span>
            <span v-else-if="!scope.row.railwayStatus?.length"> --- </span>
            <span v-else>
              <el-popover effect="dark" placement="top-start" :width="400" trigger="hover" :content="scope.row.railwayStatus">
                <template #reference> {{ scope.row.railwayStatus?.slice(0, 15) }}... </template>
              </el-popover>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="站线状态修" prop="stationStatus">
          <template #default="scope">
            <span v-if="scope.row.stationStatus?.length <= 15">
              {{ scope.row.stationStatus }}
            </span>
            <span v-else-if="!scope.row.stationStatus?.length"> --- </span>
            <span v-else>
              <el-popover effect="dark" placement="top-start" :width="400" trigger="hover" :content="scope.row.stationStatus">
                <template #reference> {{ scope.row.stationStatus?.slice(0, 15) }}... </template>
              </el-popover>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="道岔状态修" prop="turnoutStatus">
          <template #default="scope">
            <span v-if="scope.row.turnoutStatus?.length <= 15">
              {{ scope.row.turnoutStatus }}
            </span>
            <span v-else-if="!scope.row.turnoutStatus?.length"> --- </span>
            <span v-else>
              <el-popover effect="dark" placement="top-start" :width="400" trigger="hover" :content="scope.row.turnoutStatus">
                <template #reference> {{ scope.row.turnoutStatus?.slice(0, 15) }}... </template>
              </el-popover>
            </span>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog title="审批" v-model="isApprovalShow" width="550px" append-to-body draggable>
      <el-form ref="form" :model="examineForma" :rules="examineRules" label-width="100px" :inline="true">
        <el-form-item label="处理节点" prop="nodeName">
          <el-input style="width: 380px" disabled v-model="examineForma.nodeName" placeholder="请输入处理节点" />
        </el-form-item>
        <el-form-item label="处理人" prop="userName">
          <el-input disabled style="width: 380px" v-model="examineForma.userName" placeholder="请输入处理人" />
        </el-form-item>
        <el-form-item label="审批意见" prop="action">
          <el-select clearable style="width: 380px" v-model="examineForma.action" placeholder="请选择">
            <el-option v-for="dict in ExamineFormobj" :key="dict.id" :label="dict.label" :value="dict.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="更多意见" prop="comment" :required="examineForma.action == 'jumpreject' || examineForma.action == 'reject'">
          <el-input
            style="width: 380px"
            v-model="examineForma.comment"
            type="textarea"
            :autosize="{ minRows: 3, maxRows: 3 }"
            placeholder="请输入内容"
          />
        </el-form-item>
      </el-form>
      <div class="calssdivsub">
        <el-button type="success" @click="examineForm" style="width: 80px">提交</el-button>
        <el-button type="success" @click="cancel" style="width: 80px">取消</el-button>
      </div>
    </el-dialog>
    <el-dialog title="选择模板" v-model="isShowselectionProcessDialog" width="700px" append-to-body draggable>
      <selectProcessVue
        v-if="isShowselectionProcessDialog"
        :isShowselectionProcessList="isShowselectionProcessList"
        @parentselectChangeionProcess="parentselectChangeionProcess"
        :submitCheckbox="submitCheckbox"
      ></selectProcessVue>
    </el-dialog>
    <el-dialog title="选择退回节点" v-model="returnNodeShow" width="400px" append-to-body draggable>
      <span style="font-size: 15px">退回节点:</span>
      <el-select clearable style="width: 180px" v-model="returnModel" placeholder="请选择">
        <el-option v-for="dict in returnFormobj" :key="dict.nodeId" :label="dict.nodeName" :value="dict.nodeId"></el-option>
      </el-select>
      <div class="calssdivsub">
        <el-button type="primary" @click="returnClickFun" style="width: 80px">提交</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script setup name="intelligence">
import useUserStore from "@/store/modules/user";
const userStore = useUserStore();
import selectProcessVue from "@/components/planModle/selectProcess.vue";
import tree from "./tree.vue";
defineExpose({ getList1 });
import { selectWorkflowStatusapi } from "@/api/main/api.js";
import {
  selectProYearExaminePlanList,
  examineBtcPlan,
  examineRailway,
  selectProYearBtcList,
  selectProYearRailwayList,
  examineMaintainPlan,
} from "@/api/main/yearPlan.js";
import { listplan } from "@/api/main/dataDictionary.js";
const { proxy } = getCurrentInstance();
import { nextTick, ref } from "vue";
const isShowWorkArea = ref(false);
const isShowtrajectory = ref(false);
const isShowselectionProcessDialog = ref(false);
const isShowlook = ref(false);

const props = defineProps({
  examineStatusobj: {
    type: Array,
    default: [],
  },
  readConverterExp: {
    type: Number,
    default: 1,
  },
  isqsh: {
    type: String,
    default: "",
  },
  zfspmc: {
    type: String,
    default: "年计划-年度桥隧函维修计划-作废",
  },
});
const data = reactive({
  paramsintel: {
    organizationName: "",
    organizationId: "",
    year: "",
    examineStatus: "",
    type: null,
  },
  intelligenceList: [],
  operationTrajectory: [],
  detaildata: [],
  examineForma: {
    nodeName: "",
    userName: "",
    action: "",
    comment: "",
  },
  examineRules: {
    nodeName: [
      {
        required: true,
        message: "处理节点不能为空",
        trigger: ["blur", "change"],
      },
    ],
    userName: [
      {
        required: true,
        message: "处理人不能为空",
        trigger: ["blur", "change"],
      },
    ],
    action: [
      {
        required: true,
        message: "审批意见不能为空",
        trigger: ["blur", "change"],
      },
    ],
    comment: [
      {
        required: false,
        message: "更多意见不能为空",
        trigger: ["blur", "change"],
      },
    ],
    isShowselectionProcessList: [],
  },
  returnNodeShow: false,
  returnFormobj: [],
  returnModel: "",
  forma: {
    examineStatus: "",
  },
});
const {
  paramsintel,
  intelligenceList,
  operationTrajectory,
  examineForma,
  examineRules,
  isShowselectionProcessList,
  returnNodeShow,
  returnModel,
  returnFormobj,
  forma,
  detaildata,
} = toRefs(data);
const cancelFunsubmit = ref(false);
// 查询表格数据
function getList1(num) {
  paramsintel.value.type = props.readConverterExp;
  paramsintel.value.token = sessionStorage.getItem("accessToken");
  selectProYearExaminePlanList(paramsintel.value).then((res) => {
    if (res.code == 200) {
      intelligenceList.value = res.data;
    }
  });
}
//单位
function focusWorkArea() {
  isShowWorkArea.value = true;
}
//树结构的选择单选
function handleCheckTree(data) {
  paramsintel.value.organizationName = data.organizationFullName;
  paramsintel.value.organizationId = data.organizationId;
}
function paramsintelReset() {
  paramsintel.value = {
    organizationName: "",
    organizationId: "",
    maintainType: "",
  };
  getList1();
}

function look(row) {
  let obj = {
    pageNum: 1,
    pageSize: 999999,
    userId: sessionStorage.getItem("userId"),
    token: sessionStorage.getItem("accessToken"),
    examinePlanId: row.id,
  };
  if (paramsintel.value.type == 1) {
    selectProYearBtcList(obj).then((res) => {
      if (res.code == 200) {
        detaildata.value = res.data;
        isShowlook.value = true;
      }
    });
  } else {
    selectProYearRailwayList(obj).then((res) => {
      if (res.code == 200) {
        detaildata.value = res.data;
        isShowlook.value = true;
      }
    });
  }
}
function trajectory(row) {
  let obj = {
    accessToken: sessionStorage.getItem("accessToken"),
    workId: row.workId,
    skipFields: "isover;limittime;actionname;dotime;dotimemin;flowname;flowid;id",
  };
  proxy.PsotaxiosFunction(obj, "flow/support/history").then((res) => {
    if (res.code == 0) {
      for (let i = 0; i < res.data.length; i++) {
        const element = res.data[i];
        if (element.action == "Submit") {
          element.actionName = "同意";
        } else if (element.action == "Reject" || element.action == "Jumpreject") {
          element.actionName = "驳回";
        }
      }
      operationTrajectory.value = res.data;
      isShowtrajectory.value = true;
    }
  });
}
//   审批弹窗
const submitCheckbox = ref({});
const ExamineFormobj = ref([]);
const isApprovalShow = ref(false);
function Approvalfn(row) {
  forma.value.examineStatus = row.examineStatus;
  let obj = {
    accessToken: sessionStorage.getItem("accessToken"),
    workId: row.workId,
    subjectionId: row.subjectionId ? row.subjectionId : "",
    trackId: row.trackId,
    token: sessionStorage.getItem("accessToken"),
  };
  emit('shenpi', row)

  selectWorkflowStatusapi(obj).then((res) => {
    if (res.code == 200) {
      ExamineFormobj.value = [];
      examineForma.value.nodeName = res.data.nodeName;
      examineForma.value.userName = res.data.userName;
      examineForma.value.accessToken = sessionStorage.getItem("accessToken");
      examineForma.value.workId = res.data.workId;
      examineForma.value.trackId = res.data.trackId;
      examineForma.value.subjectionId = res.data.subjectionId;
      examineForma.value.nodeId = res.data.nodeId;
      examineForma.value.planId = row.id;
      examineForma.value.isReader = row.isReader;
      if (res.data.flowButtons != null) {
        for (let i = 0; i < res.data.flowButtons.length; i++) {
          const element = res.data.flowButtons[i];
          if (element.buttonName == "提交") {
            ExamineFormobj.value.push({
              label: "同意",
              value: "submit",
            });
          } else if (element.buttonName == "退回") {
            ExamineFormobj.value.push({
              label: "驳回",
              value: "reject",
            });
          } else if (element.buttonName == "任意退回") {
            ExamineFormobj.value.push({
              label: "任意驳回",
              value: "jumpreject",
            });
          }
        }
        isApprovalShow.value = true;
      }
    }
  });
}
const emit = defineEmits(["call-parent-method","shenpi"]);
const isSubmitWork = ref(false);
function examineForm() {
  if (examineForma.value.action != "") {
    if (examineForma.value.action == "jumpreject" || examineForma.value.action == "reject") {
      if (examineForma.value.comment == "") {
        return proxy.$modal.msgError("更多意见不能为空");
      }
    }
  } else {
    return proxy.$modal.msgError("审批意见不能为空");
  }

  if (examineForma.value.action == "reject") {
    examineForma.value.examineStatus = 1;
  } else {
    examineForma.value.examineStatus = 0;
  }

  if (cancelFunsubmit.value == true) {
    examineForma.value.isCance = true;
  } else {
    if (forma.value.examineStatus == "作废审核中" || forma.value.examineStatus == "作废驳回") {
      examineForma.value.isCance = true;
    } else {
      examineForma.value.isCance = false;
    }
  }
  // console.log(examineForma.value)
  if (props.isqsh == "qsh") {
    examineBtcPlan(examineForma.value).then((res) => {
      if (res.code == 200) {
        isApprovalShow.value = false;
        getList1();
        emit("call-parent-method");
        return proxy.$modal.msgSuccess("提交成功");
      } else if (res.code == 4) {
        res.data.action = examineForma.value.action;
        submitCheckbox.value = res.data;
        isSubmitWork.value = true;
        isShowselectionProcessDialog.value = true;
      } else if (res.code == 2) {
        if (examineForma.value.action == "jumpreject") {
          res.data.action = examineForma.value.action;
          returnFormobj.value = res.data.nextNode;
          returnNodeShow.value = true;
        } else {
          isApprovalShow.value = false;
          getList1();
          emit("call-parent-method");
          return proxy.$modal.msgSuccess("提交成功");
        }
      }
    });
  } else {
    examineRailway(examineForma.value).then((res) => {
      if (res.code == 200) {
        isApprovalShow.value = false;
        getList1();
        emit("call-parent-method");
        return proxy.$modal.msgSuccess("提交成功");
      } else if (res.code == 4) {
        res.data.action = examineForma.value.action;
        submitCheckbox.value = res.data;
        isSubmitWork.value = true;
        isShowselectionProcessDialog.value = true;
      } else if (res.code == 2) {
        if (examineForma.value.action == "jumpreject") {
          res.data.action = examineForma.value.action;
          returnFormobj.value = res.data.nextNode;
          returnNodeShow.value = true;
        } else {
          isApprovalShow.value = false;
          getList1();
          emit("call-parent-method");
          return proxy.$modal.msgSuccess("提交成功");
        }
      }
    });
  }
}
function cancel() {
  isApprovalShow.value = false;
  examineForma.value = {
    nodeName: "",
    userName: "",
    action: "",
    comment: "",
  };
}
//任意驳回
function returnClickFun() {
  if (returnModel.value != "") {
    let obj = {};
    obj.accessToken = sessionStorage.getItem("accessToken");
    obj.planId = examineForma.value.planId;
    obj.trackId = examineForma.value.trackId;
    obj.userName = examineForma.value.userName;
    obj.workId = examineForma.value.workId;
    obj.comment = examineForma.value.comment;
    obj.action = "jumpreject";
    obj.isSelect = true;
    if (obj.action == "jumpreject") {
      obj.examineStatus = 0;
    } else {
      if (forma.value.examineStatus == "审核中" || forma.value.examineStatus == "作废审核中" || forma.value.examineStatus == "作废驳回") {
        obj.examineStatus = 0;
      } else {
        obj.examineStatus = 1;
      }
    }
    let arr = [];
    for (let i = 0; i < returnFormobj.value.length; i++) {
      const element = returnFormobj.value[i];
      if (element.nodeId == returnModel.value) {
        element.isSelect = true;
        arr.push(element);
      }
    }
    obj.nextNodes = arr;
    if (forma.value.examineStatus == "作废审核中" || forma.value.examineStatus == "作废驳回") {
      obj.isCance = true;
    } else {
      obj.isCance = false;
    }
    examineMaintainPlan(obj).then((res) => {
      if (res.code == 200) {
        returnNodeShow.value = false;
        open.value = false;
        proxy.$modal.msgSuccess("提交成功");
        getList1();
        emit("call-parent-method");
      }
    });
  } else {
    return proxy.$modal.msgError("退回节点不能为空");
  }
}
//提交审批中的确认
function parentselectChangeionProcess(radioSelectlistUserList, isReader, selectlistUserList) {
  submitCheckbox.value.accessToken = sessionStorage.getItem("accessToken");
  //通过当前条的提交审批过来的
  if (isSubmitWork.value) {
    if (cancelFunsubmit.value == true) {
      submitCheckbox.value.isCance = true;
    } else {
      if (forma.value.examineStatus == "作废审核中" || forma.value.examineStatus == "作废驳回") {
        submitCheckbox.value.isCance = true;
      } else {
        submitCheckbox.value.isCance = false;
      }
    }
    if (examineForma.value.examineStatus == "驳回") {
      submitCheckbox.value.action = "jumpreject";
    } else {
      submitCheckbox.value.action = "submit";
    }
    if (submitCheckbox.value.selectType == "radio") {
      submitCheckbox.value.userIds = radioSelectlistUserList.userId;
      submitCheckbox.value.isReader = isReader;
      submitCheckbox.value.comment = submitCheckbox.value.comment;
      submitCheckbox.value.selectAuthor = [radioSelectlistUserList];
      if (props.isqsh == "qsh") {
        examineBtcPlan(submitCheckbox.value).then((res) => {
          if (res.code == 200) {
            proxy.$modal.msgSuccess("提交成功");
            isShowselectionProcessDialog.value = false;
            isApprovalShow.value = false;
            isSubmitWork.value = false;
            getList1();
            emit("call-parent-method");
            workIdParam.value = null;
            workIdParam.value = examineForma.value.workId;
          }
        });
      } else {
        examineRailway(submitCheckbox.value).then((res) => {
          if (res.code == 200) {
            proxy.$modal.msgSuccess("提交成功");
            isShowselectionProcessDialog.value = false;
            isApprovalShow.value = false;
            isSubmitWork.value = false;
            getList1();
            emit("call-parent-method");
            workIdParam.value = null;
            workIdParam.value = examineForma.value.workId;
          }
        });
      }
    } else if (submitCheckbox.value.selectType == "checkbox") {
      for (let i = 0; i < selectlistUserList.length; i++) {
        const element = selectlistUserList[i];
        if (i == 0) {
          submitCheckbox.value.userIds = element.userId;
        } else {
          submitCheckbox.value.userIds += ";" + element.userId;
        }
      }
      submitCheckbox.value.selectAuthor = selectlistUserList;
      submitCheckbox.value.isReader = isReader;
      submitCheckbox.value.comment = submitCheckbox.value.comment;
      if (props.isqsh == "qsh") {
        examineBtcPlan(submitCheckbox.value).then((res) => {
          if (res.code == 200) {
            proxy.$modal.msgSuccess("提交成功");
            isShowselectionProcessDialog.value = false;
            isApprovalShow.value = false;
            isSubmitWork.value = false;
            getList1();
            emit("call-parent-method");
            workIdParam.value = null;
            workIdParam.value = examineForma.value.workId;
          }
        });
      } else {
        examineRailway(submitCheckbox.value).then((res) => {
          if (res.code == 200) {
            proxy.$modal.msgSuccess("提交成功");
            isShowselectionProcessDialog.value = false;
            isApprovalShow.value = false;
            isSubmitWork.value = false;
            getList1();
            emit("call-parent-method");
            workIdParam.value = null;
            workIdParam.value = examineForma.value.workId;
          }
        });
      }
    }
    //首页上的提交审批按钮和新增的提交审批按钮
  } else {
    if (submitCheckbox.value.selectType == "radio") {
      submitCheckbox.value.userIds = radioSelectlistUserList.userId;
      submitCheckbox.value.isReader = isReader;
      submitCheckbox.value.comment = "";
      submitCheckbox.value.selectAuthor = [radioSelectlistUserList];
      submitCheckbox.value.examineStatus = 1;
      submitCheckbox.value.action = "submit";
      submitCheckbox.value.isCance = cancelFunsubmit.value;
      if (props.isqsh == "qsh") {
        examineBtcPlan(submitCheckbox.value).then((res) => {
          if (res.code == 200) {
            proxy.$modal.msgSuccess("提交成功");
            isShowselectionProcessDialog.value = false;
            isApprovalShow.value = false;
            isSubmitWork.value = false;
            getList1();
            emit("call-parent-method");
            workIdParam.value = null;
            workIdParam.value = examineForma.value.workId;
          }
        });
      } else {
        examineRailway(submitCheckbox.value).then((res) => {
          if (res.code == 200) {
            proxy.$modal.msgSuccess("提交成功");
            isShowselectionProcessDialog.value = false;
            isApprovalShow.value = false;
            isSubmitWork.value = false;
            getList1();
            emit("call-parent-method");
            workIdParam.value = null;
            workIdParam.value = examineForma.value.workId;
          }
        });
      }
    } else if (submitCheckbox.value.selectType == "checkbox") {
      for (let i = 0; i < selectlistUserList.length; i++) {
        const element = selectlistUserList[i];
        if (i == 0) {
          submitCheckbox.value.userIds = element.userId;
        } else {
          submitCheckbox.value.userIds += ";" + element.userId;
        }
      }
      submitCheckbox.value.selectAuthor = selectlistUserList;
      submitCheckbox.value.isReader = isReader;
      submitCheckbox.value.comment = "";
      submitCheckbox.value.examineStatus = 1;
      submitCheckbox.value.action = "submit";
      submitCheckbox.value.isCance = cancelFunsubmit.value;
      if (props.isqsh == "qsh") {
        examineBtcPlan(submitCheckbox.value).then((res) => {
          if (res.code == 200) {
            proxy.$modal.msgSuccess("提交成功");
            isShowselectionProcessDialog.value = false;
            isApprovalShow.value = false;
            isSubmitWork.value = false;
            getList1();
            emit("call-parent-method");
            workIdParam.value = null;
            workIdParam.value = examineForma.value.workId;
          }
        });
      } else {
        examineRailway(submitCheckbox.value).then((res) => {
          if (res.code == 200) {
            proxy.$modal.msgSuccess("提交成功");
            isShowselectionProcessDialog.value = false;
            isApprovalShow.value = false;
            isSubmitWork.value = false;
            getList1();
            emit("call-parent-method");
            workIdParam.value = null;
            workIdParam.value = examineForma.value.workId;
          }
        });
      }
    }
  }
}

//作废
function cancelFun(row) {
  proxy.$modal
    .confirm("请确定是否作废该条记录？")
    .then(function () {
      let obj = {
        accessToken: sessionStorage.getItem("accessToken"),
        isCreate: true,
        templateType: props.zfspmc,
        planId: row.id,
        action: "submit",
        examineStatus: 2,
        isCance: true,
      };
      if (props.isqsh == "qsh") {
        examineBtcPlan(obj).then((res) => {
          if (res.code == 200) {
            open.value = false;
            emit("call-parent-method");
            return proxy.$modal.msgSuccess("作废成功");
          } else if (res.code == 4) {
            //判断是不是首页的单选提交审批
            isSubmitWork.value = true;
            //判断是不是驳回,true是
            cancelFunsubmit.value = true;
            submitCheckbox.value = res.data;
            isShowselectionProcessDialog.value = true;
          }
        });
      } else {
        examineRailway(obj).then((res) => {
          if (res.code == 200) {
            open.value = false;
            getList();
            emit("call-parent-method");
            return proxy.$modal.msgSuccess("作废成功");
          } else if (res.code == 4) {
            //判断是不是首页的单选提交审批
            isSubmitWork.value = true;
            //判断是不是驳回,true是
            cancelFunsubmit.value = true;
            submitCheckbox.value = res.data;
            isShowselectionProcessDialog.value = true;
          }
        });
      }
    })

    .catch(() => {});
}
</script>
<style scoped lang="scss">
.buttonclass {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
</style>
